<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提醒事项</title>
    <script src="js/vue.js"></script>
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f4f4f4;
        }
        .app {
            width: 500px;
            min-height: 300px;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            background-color: #fff;
        }
        .header {
            height: 120px;
            background-color: orange;
            padding: 20px;
            box-sizing: border-box;
        }
        .header h1 {
            margin: 0 0 10px;
            font-size: 24px;
            color: #fff;
            text-align: left;
        }
        .header .input-container {
            display: flex;
            align-items: center;
        }
        .header input[type="text"] {
            flex: 1;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            margin-right: 10px;
        }
        .header button {
            padding: 10px 20px;
            background-color: #fff;
            color: orange;
            border: 1px solid #ccc;
            border-radius: 4px;
            cursor: pointer;
        }
        .header button:hover {
            background-color: #f9f9f9;
        }
        .content {
            background-color: #f4f4f4;
            flex: 1;
            overflow-y: auto;
            padding: 10px;
            border-radius: 0 0 8px 8px;
        }
        .content .item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0;
            border-bottom: 1px solid #ddd;
        }
        .content .item:last-child {
            border-bottom: none;
        }
        .content .item .details {
            display: flex;
            align-items: center;
        }
        .content .item .details span:first-child {
            margin-right: 10px;
            font-weight: bold;
        }
        .content .item .buttons button {
            margin-left: 5px;
            padding: 5px 10px;
            background-color: olive;
            border: 1px solid #ccc;
            border-radius: 4px;
            cursor: pointer;
            color: #fff;
        }
        .content .item .buttons button[disabled] {
            background-color: #ccc;
            cursor: not-allowed;
        }
        /* 动画过渡样式 */
        .list-move {
            transition: transform 0.5s ease;
        }
        .list-enter-active, .list-leave-active {
            transition: all 0.5s ease;
        }
        .list-enter-from, .list-leave-to {
            opacity: 0;
            transform: translateX(30px);
        }
    </style>
</head>
<body>
    <div class="app">
        <div class="header">
            <h1>提醒事项</h1>
            <div class="input-container">
                <input v-model="title" type="text" placeholder="输入提醒事项">
                <button @click="add">添加</button>
            </div>
        </div>
        <div class="content">
            <transition-group name="list" tag="div">
                <div class="item" v-for="(item, index) in list" :key="item">
                    <div class="details">
                        <span>{{ index + 1 }}.</span>
                        <span>{{ item }}</span>
                    </div>
                    <div class="buttons">
                        <button v-if="index < list.length - 1" @click="moveDown(index)">下移</button>
                        <button v-else disabled>下移</button>
                        <button v-if="index > 0" @click="moveUp(index)">上移</button>
                        <button v-else disabled>上移</button>
                        <button @click="removeItem(index)">删除</button>
                    </div>
                </div>
            </transition-group>
        </div>
    </div>
    <script>
        Vue.createApp({
            data() {
                return {
                    title: '',
                    list: ["吃饭", "睡觉", "运动"]
                };
            },
            methods: {
                add() {
                    if (this.title.trim().length <= 0) {
                        alert('请输入事项名称');
                        return;
                    }
                    this.list.push(this.title);
                    this.title = ''; // 清空输入框
                },
                moveUp(index) {
                    if (index > 0) {
                        const temp = this.list[index];
                        this.list[index] = this.list[index - 1];
                        this.list[index - 1] = temp;
                    }
                },
                moveDown(index) {
                    if (index < this.list.length - 1) {
                        const temp = this.list[index];
                        this.list[index] = this.list[index + 1];
                        this.list[index + 1] = temp;
                    }
                },
                removeItem(index) {
                    this.list.splice(index, 1);
                }
            }
        }).mount(".app");
    </script>
</body>
</html>